package com.check.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.check.dao.DataSumDao;
import com.check.pojo.MarkDataSum;
import com.check.pojo.MarkRole;
import com.check.pojo.MarkTable;
import com.check.pojo.PageObject;

@Repository("dataSumDao")
public class DataSumDaoImpl extends BaseSqlMapDao implements DataSumDao{

	public int countQueryByYear(String checkYear) {
		return ((Integer) getSqlMapClientTemplate().queryForObject("MarkDataSum.findCountByCheckYear",checkYear)).intValue();
	}

	public int countQueryByUnChg(String checkYear) {
		return ((Integer) getSqlMapClientTemplate().queryForObject("MarkDataSum.findCountUnMarked",checkYear)).intValue();
	}

	public void deleteMarkDataSum(String checkYear) {
		deleteObject("MarkDataSum.deleteMarkDataSum", checkYear);
	}

	public void insertDeptBatch(String checkYear) {
		
		insertObject("MarkDataSum.insertDeptSumBatch", checkYear);
		
	}

	public void updatePerson(String checkYear) {
		updateObject("MarkDataSum.updateMarkDataSumPerson", checkYear);
	}

	public void updatePersonNull(String checkYear) {
		updateObject("MarkDataSum.updateMarkDataSumPersonNull", checkYear);
		
	}

	public void insertPersonBatch(String checkYear) {
		insertObject("MarkDataSum.insertPersonSumBatch", checkYear);
	}

	public void doProceOrgan(String checkYear) {
		getSqlMapClientTemplate().queryForList("MarkDataSum.procedureOrderOrgan",checkYear);
	}

	public void doProceOffice(String checkYear) {
		getSqlMapClientTemplate().queryForList("MarkDataSum.procedureOrderOffice",checkYear);
	}

	public void doProceCheckOrg(String checkYear) {
		getSqlMapClientTemplate().queryForList("MarkDataSum.procedureOrderCheckIdOrgan",checkYear);
	}

	public void doProceCheckOff(String checkYear) {
		getSqlMapClientTemplate().queryForList("MarkDataSum.procedureOrderCheckIdOffice",checkYear);
	}

	public List findPersonQueryDetailMarkMeasure(Map map,PageObject pageObject) {
		if(pageObject == null){
			return getSqlMapClientTemplate().queryForList("MarkDataSum.personQueryDetailMeasure",map);
		}else{
			int pageSize=pageObject.getPageCount();
			int start =(pageObject.getCurrent()-1)*pageSize;
			return getSqlMapClientTemplate().queryForList("MarkDataSum.personQueryDetailMeasure",map,start,pageSize);
		}
		
	}

	public List findPersonQueryDetailMarkRole(MarkDataSum markDataSum) {
		return getSqlMapClientTemplate().queryForList("MarkDataSum.personQueryDetailMarkRole",markDataSum);
	}

	public List<MarkRole> findAllMarkRoleByCheckMarkRoleId(String checkMarkRoleId) {
		return getSqlMapClientTemplate().queryForList("MarkDataSum.findAllMarkRoleByCheckMarkRoleId",checkMarkRoleId);
	}

	public List findPersonQueryDetailMarkRole(Map map,PageObject pageObject) {
		if(pageObject==null){
			if("".equals(map.get("sql1")) || "".equals(map.get("sql2"))){
				
				return getSqlMapClientTemplate().queryForList("MarkDataSum.personQueryDetailMarkRoleByMapOneYear",map);
			}else{
				return  getSqlMapClientTemplate().queryForList("MarkDataSum.personQueryDetailMarkRoleByMap",map);
			}
		}else{
			int pageSize=pageObject.getPageCount();
			int start = (pageObject.getCurrent() - 1) * pageSize;
			if("".equals(map.get("sql1")) || "".equals(map.get("sql2"))){
				return getSqlMapClientTemplate().queryForList("MarkDataSum.personQueryDetailMarkRoleByMapOneYear",map,start,pageSize);
			}else{
				return getSqlMapClientTemplate().queryForList("MarkDataSum.personQueryDetailMarkRoleByMap",map,start,pageSize);
			}
			
		}
	}

	public List<MarkTable> findMarkTable(Map map) {
		
		return getSqlMapClientTemplate().queryForList("MarkDataSum.findMarkTable",map);
	}

	public List findAgencyQueryDetailMarkMeasure(Map map, PageObject pageObject) {
		if(pageObject == null){
			return getSqlMapClientTemplate().queryForList("MarkDataSum.agencyQueryDetailMeasure",map);
		}else{
			int pageSize=pageObject.getPageCount();
			int start =(pageObject.getCurrent()-1)*pageSize;
			return getSqlMapClientTemplate().queryForList("MarkDataSum.agencyQueryDetailMeasure",map,start,pageSize);
		}
	}
	
	public List<MarkTable> findAgencyMarkTable(Map map){
		return getSqlMapClientTemplate().queryForList("MarkDataSum.findAgencyMarkTable",map);
	}

	public List<MarkRole> findAllAgencyMarkRoleByCheckMarkRoleId(String checkMarkRoleId){
		return getSqlMapClientTemplate().queryForList("MarkDataSum.findAllAgencyMarkRoleByCheckMarkRoleId",checkMarkRoleId);
	}

	public List findAgencyQueryDetailMarkRole(Map map, PageObject pageObject) {
		if(pageObject==null){
			if("".equals(map.get("sql1")) || "".equals(map.get("sql2"))){
				
				return getSqlMapClientTemplate().queryForList("MarkDataSum.agencyQueryDetailMarkRoleByMapOneYear",map);
			}else{
				return  getSqlMapClientTemplate().queryForList("MarkDataSum.agencyQueryDetailMarkRoleByMap",map);
			}
		}else{
			int pageSize=pageObject.getPageCount();
			int start = (pageObject.getCurrent() - 1) * pageSize;
			if("".equals(map.get("sql1")) || "".equals(map.get("sql2"))){
				return getSqlMapClientTemplate().queryForList("MarkDataSum.agencyQueryDetailMarkRoleByMapOneYear",map,start,pageSize);
			}else{
				return getSqlMapClientTemplate().queryForList("MarkDataSum.agencyQueryDetailMarkRoleByMap",map,start,pageSize);
			}
			
		}
	}

	public List findAllPersonAnalyseByCheckMarkRoleId(Map map) {
		if("".equals(map.get("sql1")) || "".equals(map.get("sql2"))){
			return getSqlMapClientTemplate().queryForList("MarkDataSum.personQueryDetailMarkRoleByMapOneYear",map);
		}else{
			return  getSqlMapClientTemplate().queryForList("MarkDataSum.personQueryDetailMarkRoleByMap",map);
		}
		
	}

	public List findPersonAnlayseAverageByCheckMarkRoleId(Map map) {
		
		return getSqlMapClientTemplate().queryForList("MarkDataSum.personAnalyseAverageByCheckMarkRoleId",map);
	}

	public List findAllAgencyAnalyseByCheckMarkRoleId(Map map) {
		if("".equals(map.get("sql1")) || "".equals(map.get("sql2"))){
			return getSqlMapClientTemplate().queryForList("MarkDataSum.agencyQueryDetailMarkRoleByMapOneYear",map);
		}else{
			return  getSqlMapClientTemplate().queryForList("MarkDataSum.agencyQueryDetailMarkRoleByMap",map);
		}
	}

	public List findAgencyAnlayseAverageByCheckMarkRoleId(Map map) {
		return getSqlMapClientTemplate().queryForList("MarkDataSum.agencyAnalyseAverageByCheckMarkRoleId",map);
	}

	public void doProcePerson(String checkYear, String m_id) {
		Map map=new HashMap();
		map.put("checkYear", checkYear);
		map.put("markRoleId", m_id);
		getSqlMapClientTemplate().queryForList("MarkDataSum.doProcePerson",map);
		
	}

	public void doProceAgency(String checkYear, String m_id) {
		Map map=new HashMap();
		map.put("checkYear", checkYear);
		map.put("markRoleId", m_id);
		getSqlMapClientTemplate().queryForList("MarkDataSum.doProceAgency",map);
	}

	public List findPersonAnalyseWithMorkYear(Map map) {
		return getSqlMapClientTemplate().queryForList("MarkDataSum.personAnalyseWithMoreYear",map);
	}

	public List findPersonAnalyseWithMorkYearAverage(Map map) {
		return getSqlMapClientTemplate().queryForList("MarkDataSum.personAnalyseWithMoreYearAverage",map);
	}

	public List findAgencyAnalyseWithMorkYear(Map map) {
		return getSqlMapClientTemplate().queryForList("MarkDataSum.agencyAnalyseWithMoreYear",map);
	}

	public List findAgencyAnalyseWithMorkYearAverage(Map map) {
		return getSqlMapClientTemplate().queryForList("MarkDataSum.agencyAnalyseWithMoreYearAverage",map);
	}
}
